{include file="common:header" /}
{include file="common:side" /}
<style>
  .row{
    display: flex;
    flex-wrap: wrap;
  }
 @media (max-width: 768px){
   .col-sm-3 {
      width: 270px;
  }
 }
 .box{
  width: 110px;
 }
 
</style>
    <div id="page-wrapper">
      <!-- 舆情日报 -->
      <!--*************************** content部分开始 ******************-->
      <div class="container-fluid" id="m_main">
        <div class="row m-t-20">
          <div class="col-sm-12">
            <div class="white-box">
              <h2 class="box-title m-b-20">课件授权</h2>
              <div class="row">
                <div class="col-sm-4">
                  <div class="form-group">
                    <label class="control-label">课件名称</label>
                    {$courseware.name}
                  </div>
                </div>
              </div>
              <div class="row">
                {foreach $store as $key=>$vo } 
                <div class="col-sm-3 ">
                  <div class="form-group conItem">
                    <input type="checkbox" value="{$vo.id}" {in name="$vo.id" value="$courseware_authorize"}checked{/in} id="cb1" class="ch" @click="checkboxOnclick1()" />
                      <div style="background-color: #F2F2F2;padding: 10px 20px;width: 110px;">
                        <div class="conItemed" style="width: 100%;display:flex; flex-direction:column; align-items: center">
                          
                          <img src="{$vo.avatar}" alt="" style="height:70px;width: 70px;">
                          <span style="margin-top: 4px">
                            {$vo.name}
                          </span>
                        </div>
                      </div>
                  </div>
                </div>
                {/foreach}
              </div>
              <!-- <div class="row">
                <div class="col-sm-4 form-list">
                  <div class="form-group ">
                    <label class="control-label">课程学生：</label>
                      <ul class="students-ul">
                        <li class="students-li" v-for="(item,index) in students" :key='index'>
                          <img :src="item.img" alt="">
                          <div class="studentName">{{item.name}}</div>
                        </li>
                      </ul>
                  </div>
                </div>
              </div> -->
              <div class="row m-t-40">
                <div class="col-sm-8 ta-c">
                  <button type="button" name="" class="btn btn-outline btn-primary m-r-40" @click="doSubmit()">提交</button>
                </div>
              </div>
            </div>
          </div>
        </div>

        <!-- /.row -->
      </div>
      <!--*************************** content部分结束 ******************-->

      <!-- <footer class="footer text-center"> 2017 &copy; Ample Admin brought to you by themedesigner.in </footer> -->
    </div>
  {include file="common:js" /}
  {include file="common:footer" /}
  <script src="/web/js/edit.js"></script>

  <script type="text/javascript">
    var vm = new Vue({
      el: '#m_main',
      data() {
        return {
          id: '{$id}',
          courseware: {},
          store: {},
          courseware_authorize: {},
          // students:[{
          //   img:'#',
          //   name:'zhangsan'
          // },
          // {img:'#',
          //   name:'zhangsan'
          // }],
          ids: '', // 门店
        }
      },
      mounted() {
        // this.requestData();
        this.checkboxOnclick1();
      },
      methods: {
        requestData() {
          let that = this;
          axios.post('/dboard/courseware/authorize', {id: that.id,ids: that.ids},{headers: {'X-Requested-with':'XMLHttpRequest'}}).then(res => {
            // console.log(res);
            if(res.data.Code == 0){
              that.courseware = res.data.Data.courseware;
              that.store = res.data.Data.store;
              that.courseware = res.data.Data.courseware;
            }else{
              alert(res.data.Msg)
            }
          }).catch(err => {
            console.log(err);
          })
        },
        // 提交
        doSubmit(){
          var that = this;
          var param = {
            id: that.id,  // 课件id
            ids: that.ids,  // 老师id集合
          }
          axios.post('/dboard/courseware/editCoursewareauthorize', param,{headers: {'X-Requested-with':'XMLHttpRequest'}}).then(res => {
            // console.log(res);
            if(res.data.Code == 0){
              //请求成功
              alert(res.data.Msg);
              window.location.href = '/dboard/courseware/courseware_lists';
            }else{
              alert(res.data.Msg)
            }
          }).catch(err => {
            console.log(err);
          })
        },
        checkboxOnclick1(){
          var ids = '';
          var A = $('#cb1:checked')
          A.each(function(i){
            ids = ids+$(this).val().toString()+',';
          })
          this.ids = ids;
        },
      }
    })
  </script>
  

